package dal.object.grounds;

import gui.PlayersMap;

import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;

import core.Physics;

import dal.object.Ground;
import dal.FileIO;

public class BigPit extends Ground {
	private static final BufferedImage pic = FileIO.readPic(path + "godorNagy.png");
	public static final int FRICTION_COEFFICIENT = 50;
	public static final int FORCE = 5000;
	
	public BigPit(){
		img = pic;
	}
		
	public int getFrictionCoefficient() {
		double dx = origo.x - PlayersMap.xBall;
		double dy = origo.y - PlayersMap.yBall;
		
		if(dx != 0 || dy != 0){
			double dist = Math.sqrt(dx * dx + dy * dy);
			
			if(dist > 7){
				double unit = 1 / dist * FORCE;
				
				dx = origo.x * ((dx < 0) ? -unit : unit);
				dy = origo.y * ((dy < 0) ? -unit : unit);
				
				Point2D v = Physics.getVelocity(); 
				Physics.setVelocity(dx + v.getX(), dy + v.getY());
			} else {
				double unit = 1 / dist + 50;
				
				dx = origo.x * ((dx < 0) ? -unit : unit);
				dy = origo.y * ((dy < 0) ? -unit : unit);
				
				Point2D v = Physics.getVelocity(); 
				Physics.setVelocity(dx + v.getX(), dy + v.getY());
			}
		}
		
		return FRICTION_COEFFICIENT;
	}

	public double getManoeuvrability() {
		return 1;
	}
}
